#ifndef TCPSERVER_H
#define TCPSERVER_H

/**
 * TCP server
 * auth: luo
 * date: 09 22
 */
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <string>
#include <pthread.h>
#include <vector>

// boost 
#include <boost/asio.hpp>
#include <boost/asio/thread_pool.hpp>

#include "Global.h"

struct ST_Client
{
    int soc;
    struct sockaddr_in addr;
};

class TcpServer
{
public:
    TcpServer(int port):i_port(port),b_run(false){};
    ~TcpServer();
    bool run_server();
    void stop_server();
    void setport(int port);
    //handle recv msg
    void handle_msg(int client_conn);
private:
    //server port
    int i_port;
    //server_socket
    int i_serversocket;
    //server_run_status
    bool b_run;
    //
    std::vector<ST_Client> vec_clientsocket;
    //boost thread pool
    boost::asio::thread_pool tp_pool{10};
};

#endif